﻿
@{
    var Article = (QunProject.Model.article)ViewBag.Article;
    ViewBag.Title = Article.Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
    var LoginMember = (QunProject.Model.member)ViewBag.LoginMember;
}

<script src="~/Content/script/highlight.pack.js"></script>
<link href="~/Content/style/vs2015.css" rel="stylesheet" />

<style>
    .rowUnHover:hover {
        background-color: #fff !important;
    }
</style>

<div class="layui-container p0 mt15">
    <div class="layui-row layui-col-space10">
        <div class="layui-col-md8 transition_width" id="article_content">
            <div class="article-list">
                <div class="row p20p20 bcolor oa rowUnHover">
                    <div class="layui-col-md12" id="dot_article">
                        <h1 class="pb10">
                            @Article.Title
                        </h1>
                        <i class="layui-icon readview layui-hide-xs" title="阅读模式" onclick="javascript: { article.readView(); }">&#xe705;</i>
                    </div>

                    <script id="dot_tmp_article" type="text/x-dot-template">
                        <h1 class="pb10">
                            {{= it.Title }}
                        </h1>
                        <i class="layui-icon readview layui-hide-xs" title="阅读模式" onclick="javascript: { article.readView(); }">&#xe705;</i>
                        {{? it.Source }}
                        <div class="pb5" style="color:#808080;">
                            {{? it.SourceUrl }}
                            <p>文章来源：<a href="{{= it.SourceUrl }}" target="_blank" style="color:#3488F5;">{{= it.Source }}</a></p>
                            {{?? }}
                            <p>文章来源：{{= it.Source }}</p>
                            {{? }}
                        </div>
                        {{? }}
                        <div class="panle-info">
                            <span>
                                <i class="layui-icon">&#xe637;</i> {{= it.CreateTime }}
                            </span>
                            {{? it.Number }}
                            <a href="/Page/Index/{{= it.Number }}@(ViewBag.Suffix)" class="href" style="font-size:12px;" target="_blank">
                                <i class="layui-icon" style="font-size:13px;">&#xe612;</i> {{= it.UserName }}
                            </a>
                            <span style="margin-left:10px;">
                                <i class="layui-icon">&#xe60c;</i> {{= it.Praise }}
                            </span>
                            {{?? }}
                            <span>
                                <i class="layui-icon">&#xe612;</i> {{= it.UserName }}
                            </span>
                            <span>
                                <i class="layui-icon">&#xe60c;</i> {{= it.Praise }}
                            </span>
                            {{? }}
                            <span>
                                <i class="layui-icon">&#xe615;</i> {{= it.ClickAmount }}
                            </span>
                        </div>
                        <div class="pbt25">
                            {{= it.Content }}
                        </div>

                        {{? it.Resources.length > 0 }}
                        <hr />
                        <div>
                            <blockquote class="layui-elem-quote">
                                {{ for(var idx in it.Resources) { if(it.Resources[idx].ID) { var elm = it.Resources[idx]; }}
                                <div>{{= elm.Source }}：<a href="{{= elm.Url }}" target="_blank" class="href" style="margin-right:10px;">{{= elm.Name }}</a> {{= elm.Password ? "密码：" + elm.Password : "" }}</div>
                                {{ } } }}
                            </blockquote>
                        </div>
                        {{? }}

                        <hr />
                        <div class="text-left">
                            <div style="width:300px;float:left;">
                                <div class="bdsharebuttonbox">
                                    <a href="#" class="bds_more" data-cmd="more"></a>
                                    <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
                                    <a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
                                    <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
                                    <a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a>
                                    <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
                                    <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
                                    <a href="#" class="bds_douban" data-cmd="douban" title="分享到豆瓣网"></a>
                                    <a href="#" class="bds_copy" data-cmd="copy" title="分享到复制网址"></a>
                                </div>
                            </div>
                            <div style="float:right;margin-top:6px;">
                                <a href="javascript:void(0)" class="click-btn criticism-hover" onclick="javascript: { article.Click(0, {{= it.ID }}); }">
                                    <i class="layui-icon" style="font-size:14px;">&#xe69c;</i>&nbsp; <span id="spanCriticism">{{= it.Criticism }}</span>
                                </a>
                                <a href="javascript:void(0)" class="click-btn praise-hover" onclick="javascript: { article.Click(1, {{= it.ID }}); }" style="padding-top:5px;">
                                    <i class="layui-icon" style="font-size:16px;">&#xe60c;</i>&nbsp; <span id="spanPraise">{{= it.Praise }}</span>
                                </a>
                            </div>
                        </div>
                    </script>
                </div>
            </div>
            <div class="article-list bcolor p20p20 mt10" style="overflow:auto;">
                <div class="row rowUnHover" style="overflow:auto;">
                    <div class="layui-col-lg12">
                        <h1 class="pb10" style="float:left;">网友评论</h1>
                        <p style="float:left;margin-left:20px;color:#999999;margin-top: 16px;">文明上网理性发言，请遵守 <a href="/Helper/Reply@(ViewBag.Suffix)" class="href" target="_blank">网站服务协议及管理条例</a></p>
                    </div>
                </div>
                @if (LoginMember != null)
                {
                    <div class="row rowUnHover replyMemberReply" style="overflow:auto;display:none;">
                        <div class="layui-col-lg12">
                            <textarea class="reply_textarea" id="memberContent" rows="6" placeholder="输入评论内容，请理性发言"></textarea>
                        </div>
                        <div class="layui-col-lg12 pt10">
                            <div class="layui-col-lg6">
                                <img src="@ViewBag.FileApiUrl@LoginMember.Img" alt="头像" width="30" height="30" style="float:left;" />
                                <span class="reply_name">@LoginMember.Name</span>
                            </div>
                            <div class="layui-col-lg6 text-right">
                                <a href="javascript:void(0)" class="layui-btn layui-btn-normal layui-btn-sm" onclick="javascript: { reply.submit('memberContent'); }">发表评论</a>
                            </div>
                        </div>
                    </div>

                    <div class="row p20p20 rowUnHover replyMemberNoReply" style="overflow:auto;display:none;">
                        <div class="text-center" style="font-size:20px;color:#878788;">本文章不允许回复</div>
                    </div>
                }
                else
                {
                    <div class="row p20p20 rowUnHover replyMemberReply" style="overflow:auto;display:none;">
                        <div class="text-center" style="font-size:20px;color:#878788;">本站不支持匿名回复，请 <a href="/Login/Index@(ViewBag.Suffix)" class="href">登录</a></div>
                    </div>

                    <div class="row p20p20 rowUnHover replyMemberNoReply" style="overflow:auto;display:none;">
                        <div class="text-center" style="font-size:20px;color:#878788;">本文章不允许回复</div>
                    </div>
                }
                <div class="row pt40 rowUnHover replyMemberReply" style="overflow:auto;display:none;">
                    <div class="layui-col-lg12 p0">
                        <h2 class="pb10" style="float:left;">全部评论</h2>
                        <a href="javascript:void(0)" style="float:right;display:block;padding-top:10px;" class="sort_a" onclick="javascript: { $('.sort_a').removeClass('href'); $(this).addClass('href'); reply.paras.sort = 1; reply.getData(); }">最热</a>
                        <span style="float:right;margin-left:6px;margin-right:6px;display:block;padding-top:11px;">/</span>
                        <a href="javascript:void(0)" style="float:right;display:block;padding-top:10px;" class="sort_a href" onclick="javascript: { $('.sort_a').removeClass('href'); $(this).addClass('href'); reply.paras.sort = 0; reply.getData(); }">最新</a>
                    </div>
                </div>
                <hr style="margin-top:0;" />

                <div class="row pt20 rowUnHover" id="dot_reply" style="overflow:auto; padding-top:0;">
                    @*<div class="layui-col-lg12 p0 pt20">
                                <div class="row rowUnHover">
                                    <div class="layui-col-lg1 p0">
                                        <img class="reply-list-img" src="~/Content/img/banner.png" alt="头像" onerror="memberImageError(event)" />
                                    </div>
                                    <div class="layui-col-lg11 p0">
                                        <div class="row rowUnHover">
                                            <a href="/Page/Index/" class="href">淡云孤月</a>
                                            <span class="reply-list-time">2018-07-27 15:30</span>
                                            <a href="javascript:void(0)" class="reply-list-report">举报</a>
                                        </div>
                                        <div class="row pt10 rowUnHover">
                                            <div class="reply-list-content">这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容</div>
                                        </div>
                                        <div class="row pt10 rowUnHover">
                                            <a href="javascript:void(0)" class="reply-list-praise">
                                                <i class="layui-icon">&#xe6c6;</i> 12
                                            </a>
                                            <a href="javascript:void(0)" class="reply-list-criticism">
                                                <i class="layui-icon">&#xe6c5;</i> 5
                                            </a>
                                            <a href="javascript:void(0)" class="reply-list-reply">
                                                <i class="layui-icon">&#xe63a;</i> 回复
                                            </a>
                                        </div>
                                        <div class="row p10 mt10 reply-list-child" style="overflow:hidden;padding-top:0;">
                                            <div class="row">
                                                <div class="layui-col-lg12 p0 pt20">
                                                    <div class="row">
                                                        <a href="/Page/Index/" class="href">淡云孤月</a>
                                                        <span class="reply-list-time">2018-07-27 15:30</span>
                                                        <a href="javascript:void(0)" class="reply-list-report">举报</a>
                                                    </div>
                                                    <div class="row pt10">
                                                        <div class="reply-list-content">这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容</div>
                                                    </div>
                                                    <div class="row pt10">
                                                        <a href="javascript:void(0)" class="reply-list-praise">
                                                            <i class="layui-icon">&#xe6c6;</i> 12
                                                        </a>
                                                        <a href="javascript:void(0)" class="reply-list-criticism">
                                                            <i class="layui-icon">&#xe6c5;</i> 5
                                                        </a>
                                                        <a href="javascript:void(0)" class="reply-list-reply">
                                                            <i class="layui-icon">&#xe63a;</i> 回复
                                                        </a>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg12 p0 pt20">
                                                    <div class="row">
                                                        <a href="/Page/Index/" class="href">淡云孤月</a>
                                                        <span class="reply-list-time">2018-07-27 15:30</span>
                                                        <a href="javascript:void(0)" class="reply-list-report">举报</a>
                                                    </div>
                                                    <div class="row pt10">
                                                        <div class="reply-list-content">这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容</div>
                                                    </div>
                                                    <div class="row pt10">
                                                        <a href="javascript:void(0)" class="reply-list-praise">
                                                            <i class="layui-icon">&#xe6c6;</i> 12
                                                        </a>
                                                        <a href="javascript:void(0)" class="reply-list-criticism">
                                                            <i class="layui-icon">&#xe6c5;</i> 5
                                                        </a>
                                                        <a href="javascript:void(0)" class="reply-list-reply">
                                                            <i class="layui-icon">&#xe63a;</i> 回复
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-lg12 p0 pt20">
                                <div class="row rowUnHover">
                                    <div class="layui-col-lg1 p0">
                                        <img class="reply-list-img" src="~/Content/img/banner.png" alt="头像" onerror="memberImageError(event)" />
                                    </div>
                                    <div class="layui-col-lg11 p0">
                                        <div class="row rowUnHover">
                                            <a href="/Page/Index/" class="href">淡云孤月</a>
                                            <span class="reply-list-time">2018-07-27 15:30</span>
                                            <a href="javascript:void(0)" class="reply-list-report">举报</a>
                                        </div>
                                        <div class="row pt10 rowUnHover">
                                            <div class="reply-list-content">这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容这个是内容</div>
                                        </div>
                                        <div class="row pt10 rowUnHover">
                                            <a href="javascript:void(0)" class="reply-list-praise">
                                                <i class="layui-icon">&#xe6c6;</i> 12
                                            </a>
                                            <a href="javascript:void(0)" class="reply-list-criticism">
                                                <i class="layui-icon">&#xe6c5;</i> 5
                                            </a>
                                            <a href="javascript:void(0)" class="reply-list-reply">
                                                <i class="layui-icon">&#xe63a;</i> 回复
                                            </a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        <div class="row p20p20 rowUnHover" style="overflow:auto;">
                            <div class="text-center" style="font-size:20px;color:#878788;">还没有评论哎╮(╯▽╰)╭！</div>
                        </div>*@
                </div>

                <script id="dot_tmp_reply" type="text/x-dot-template">
                    {{? it.length > 0 }}
                    {{ for(var idx in it) { if(it[idx].ID) { var elm = it[idx]; }}
                    {{? idx > 0 }}
                    <hr />
                    {{? }}
                    <div class="layui-col-lg12 p0 pt10 pb10">
                        <div class="row rowUnHover">
                            <div class="layui-col-lg1 p0">
                                {{ console.log(fileurl + elm.Img); }}
                                <img class="reply-list-img" src="{{= fileurl + elm.Member.Img }}" alt="头像" onerror="memberImageError(event)" />
                            </div>
                            <div class="layui-col-lg11 p0">
                                <div class="row rowUnHover">
                                    <a href="/Page/Index/{{= elm.Member.Number }}@(ViewBag.Suffix)" class="href" target="_blank">{{= elm.Member.Name }}</a>
                                    <span class="reply-list-time">{{= elm.CreateTime }}</span>
                                    <a href="javascript:void(0)" class="reply-list-report" onclick="javascript: { complain(@((int)QunProject.Model.EnumHelper.ComplainType.评论),{{= elm.ID }}) }">举报</a>
                                </div>
                                <div class="row pt5 rowUnHover">
                                    <div class="reply-list-content">{{= elm.Content }}</div>
                                </div>
                                <div class="row pt5 rowUnHover">
                                    <a href="javascript:void(0)" class="reply-list-praise" onclick="javascript: { reply.Click(1, {{= elm.ID }}); }">
                                        <i class="layui-icon">&#xe6c6;</i> <span class="reply_praise_{{= elm.ID }}">{{= elm.Praise }}</span>
                                    </a>
                                    <a href="javascript:void(0)" class="reply-list-criticism" onclick="javascript: { reply.Click(0, {{= elm.ID }}); }">
                                        <i class="layui-icon">&#xe6c5;</i> <span class="reply_criticism_{{= elm.ID }}">{{= elm.Criticism }}</span>
                                    </a>
                                    @if (LoginMember != null)
                                    {
                                        <a href="javascript:void(0)" class="reply-list-reply" onclick="javascript: { $('.replyContent').slideUp(250); $('.replyContent_{{= elm.ID }}').slideDown(250);  }">
                                            <i class="layui-icon">&#xe63a;</i> 回复
                                        </a>
                                    }
                                </div>
                                <div class="row pb5 pt5 rowUnHover replyContent replyContent_{{= elm.ID }}" style="display:none;overflow:auto;">
                                    <div class="layui-col-lg12">
                                        <textarea class="reply_textarea_member" id="replyContent_{{= elm.ID }}" rows="3" placeholder="输入评论内容，请理性发言"></textarea>
                                    </div>
                                    <div class="layui-col-lg12 pt5">
                                        <div class="layui-col-lg12 text-right">
                                            <a href="javascript:void(0)" class="layui-btn layui-btn-normal layui-btn-xs" onclick="javascript: { reply.submit('replyContent_{{= elm.ID }}',{{= elm.ID }}); }">发表评论</a>
                                        </div>
                                    </div>
                                </div>
                                {{? elm.Childs.length > 0 }}
                                <div class="row p10 mt10 mt10 reply-list-child" style="overflow:hidden;padding-top:0;">
                                    <div class="row">
                                        {{ for(var idx2 in elm.Childs) { if(elm.Childs[idx2].ID) { var reply = elm.Childs[idx2]; }}
                                        {{? idx2 > 0 }}
                                        <hr />
                                        {{? }}
                                        <div class="layui-col-lg12 p0 pt10 pb10">
                                            <div class="row">
                                                <a href="/Page/Index/{{= reply.Member.Number }}@(ViewBag.Suffix)" class="href" target="_blank">{{= reply.Member.Name }}</a>
                                                <span class="reply-list-time">{{= reply.CreateTime }}</span>
                                                <a href="javascript:void(0)" class="reply-list-report" onclick="javascript: { complain(@((int)QunProject.Model.EnumHelper.ComplainType.评论),{{= reply.ID }}) }">举报</a>
                                            </div>
                                            <div class="row pt5">
                                                <div class="reply-list-content">{{= reply.Content }}</div>
                                            </div>
                                            <div class="row pt5">
                                                <a href="javascript:void(0)" class="reply-list-praise" onclick="javascript: { reply.Click(1, {{= reply.ID }}); }">
                                                    <i class="layui-icon">&#xe6c6;</i> <span class="reply_praise_{{= reply.ID }}">{{= reply.Praise }}</span>
                                                </a>
                                                <a href="javascript:void(0)" class="reply-list-criticism" onclick="javascript: { reply.Click(0, {{= reply.ID }}); }">
                                                    <i class="layui-icon">&#xe6c5;</i> <span class="reply_criticism_{{= reply.ID }}">{{= reply.Criticism }}</span>
                                                </a>
                                                @if (LoginMember != null)
                                                {
                                                    <a href="javascript:void(0)" class="reply-list-reply" onclick="javascript: { $('.replyContent').slideUp(250); $('.replyContent_{{= elm.ID }}_{{= reply.ID }}').slideDown(250);  }">
                                                        <i class="layui-icon">&#xe63a;</i> 回复
                                                    </a>
                                                }
                                            </div>
                                            <div class="row pb5 pt5 replyContent replyContent_{{= elm.ID }}_{{= reply.ID }}" style="display:none;overflow:auto;">
                                                <div class="layui-col-lg12">
                                                    <textarea class="reply_textarea_member" id="replyContent_{{= elm.ID }}_{{= reply.ID }}" rows="3" placeholder="输入评论内容，请理性发言"></textarea>
                                                </div>
                                                <div class="layui-col-lg12 pt5">
                                                    <div class="layui-col-lg12 text-right">
                                                        <a href="javascript:void(0)" class="layui-btn layui-btn-normal layui-btn-xs" onclick="javascript: { reply.submit('replyContent_{{= elm.ID }}_{{= reply.ID }}',{{= reply.ID }}); }">发表评论</a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        {{ } } }}
                                    </div>
                                </div>
                                {{? }}
                            </div>
                        </div>
                    </div>
                    {{ } } }}
                    {{?? }}
                    <div class="row p20p20 rowUnHover" style="overflow:auto;">
                        <div class="text-center" style="font-size:20px;color:#878788;">还没有评论哎╮(╯▽╰)╭！</div>
                    </div>
                    {{? }}
                </script>


                <div id="pageReply" class="row p20p10 oa tcenter rowUnHover">

                </div>
            </div>
        </div>
        <div class="layui-col-md4" id="article_option">
            <div class="row layui-hide-xs">
                <div class="layui-tab layui-tab-brief bcolor oa m0">
                    <ul class="layui-tab-title">
                        <li class="layui-this">知识分类</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show lh30" id="dot_classify"></div>

                        <script id="dot_tmp_classify" type="text/x-dot-template">
                            {{? it.length }}
                            {{ for(var idx in it) { if(it[idx].ID) { var elm = it[idx]; }}
                            <a href="/article/index/{{= elm.ID }}@(ViewBag.Suffix)"><span class="layui-badge layui-bg-blue">{{= elm.Name }}</span></a>
                            {{ } } }}
                            {{?? }}
                            <a href="javascript:void(0)">{{= noDataTitle }}</a>
                            {{? }}
                        </script>
                    </div>
                </div>
            </div>

            <div class="row layui-hide-xs">
                <div class="layui-tab layui-tab-brief bcolor oa">
                    <ul class="layui-tab-title">
                        <li class="layui-this">推荐文章</li>
                    </ul>
                    <div class="layui-tab-content pb0">
                        <div class="layui-tab-item layui-show" id="dot_hot_art"></div>

                        <script id="dot_tmp_hot_art" type="text/x-dot-template">
                            {{? it.length }}
                            {{ for(var idx in it) { if(it[idx].ID) { var elm = it[idx]; }}
                            <div class="row oa pbt10 bt">
                                <div class="layui-col-md3">
                                    <a href="/article/info/{{= elm.ID }}@(ViewBag.Suffix)">
                                        <img src="{{= fileurl + elm.Img }}" alt="" style="width:100%;" onerror="imageError(event)">
                                    </a>
                                </div>
                                <div class="layui-col-md9">
                                    <div class="new-panle">
                                        <a href="/article/info/{{= elm.ID }}@(ViewBag.Suffix)">
                                            <div class="ahover">{{= elm.Title }}</div>
                                        </a>
                                        <div class="panle-info">
                                            <span>
                                                <i class="layui-icon">&#xe60c;</i> {{= elm.Praise }}
                                            </span>
                                            <span>
                                                <i class="layui-icon">&#xe615;</i> {{= elm.ClickAmount }}
                                            </span>
                                        </div>
                                        <div class="panle-content">
                                            {{= elm.Content }}...
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {{ } } }}
                            {{?? }}
                            <div class="row oa pbt10 bt">{{= noDataTitle }}</div>
                            {{? }}
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    var articleId = '@ViewBag.ID';
    var article = new Article();
    var reply = new Reply();
    $(function () {
        if (articleId) {
            article.paras.articleId = articleId;
            article.testPassword();
            article.getClassify();
            article.getHotArt();

            reply.paras.articleId = articleId;
        } else {
            layer.alert('参数错误');
        }
    });

    function Article() {
        this.paras = {
            articleId: null,
            password: null
        };
        this.option = {
            isClick: false
        };
        this.readView = function () {
            var display = $('#article_option').css('display');
            if (display == 'block') {
                $('#article_option').fadeToggle(250, function () {
                    $('#article_content').toggleClass('layui-col-md12');
                });
            } else {
                $('#article_content').toggleClass('layui-col-md12');
                setTimeout(function () {
                    $('#article_option').fadeToggle(250);
                }, 500);
            }
        };
        this.testPassword = function () {
            $.post('/article/GetTestArticlePassResult', article.paras, function (result) {
                if (result.data) {
                    layer.prompt({ title: '文章已加密，请输入密码', formType: 1 }, function (pass, index) {
                        layer.close(index);
                        article.paras.password = pass;
                        article.getData();
                    });
                } else {
                    article.getData();
                }
            });

        };
        this.getData = function (isLoad, next) {
            $.post('/article/GetArticleResult', article.paras, function (result) {
                var dotTmp = doT.template($("#dot_tmp_article").text());
                $("#dot_article").html(dotTmp(result.data));
                if (!result.data.IsReply) {
                    $('.replyMemberNoReply').show();
                } else {
                    $('.replyMemberReply').show();
                    reply.getData();
                }
                window._bd_share_config = {
                    "common": {
                        "bdSnsKey": {},
                        "bdText": result.data.Title,//分享的内容
                        "bdDesc": result.data.DescContent,//分享的摘要
                        "bdUrl": window.location,//分享的Url地址
                        "bdMini": "2",//下拉浮层中分享按钮的列数
                        "bdMiniList": false,//自定义下拉浮层中的分享按钮类型和排列顺序。
                        "bdPic": fileurl + result.data.Img,//分享的图片
                        "bdStyle": "1",
                        "bdSize": "24"
                    }, "share": {}
                };
                with (document) 0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
            });
        };
        this.getClassify = function () {
            $.post('/home/GetClassifyResult', {}, function (result) {
                var dotTmp = doT.template($("#dot_tmp_classify").text());
                $("#dot_classify").html(dotTmp(result.data));
            });
        };
        this.getHotArt = function () {
            $.post('/home/GetHotArticleResult', {}, function (result) {
                var dotTmp = doT.template($("#dot_tmp_hot_art").text());
                $("#dot_hot_art").html(dotTmp(result.data));
            });
        };
        this.Click = function (type, articleId) {
            if (!this.option.isClick) {
                $.post('/article/EditArticlePraiseCriticismResult', { type: type, articleId: articleId }, function (result) {
                    layer.msg('提交成功');
                    article.option.isClick = true;
                    if (type == 1) {
                        var spanPraise = parseInt($('#spanPraise').html());
                        spanPraise += 1;
                        $('#spanPraise').html(spanPraise)
                    } else {
                        var spanCriticism = parseInt($('#spanCriticism').html());
                        spanCriticism += 1;
                        $('#spanCriticism').html(spanCriticism)
                    }
                });
            } else {
                layer.msg('已经提交过');
            }
        };
    };

    function Reply() {
        this.paras = {
            articleId: null,
            page: 1,
            limit: 10,
            sort: 0,
            count: 0
        };
        this.option = {
            elem: 'pageReply',
            Click:','
        };
        this.getData = function (isLoad, next) {
            if (isLoad) { this.paras.page = next; }
            else { this.paras.paras = 1; }
            var this_obj = this;
            $.post('/reply/GetReplyListResult', this_obj.paras, function (result) {
                this_obj.paras.count = result.count;
                if (!isLoad) { this_obj.setPage(); }
                var dotTmp = doT.template($("#dot_tmp_reply").text());
                $("#dot_reply").html(dotTmp(result.data));
            });
        };
        this.setPage = function () {
            var this_obj = this;
            layui.laypage.render({
                elem: this_obj.option.elem,
                count: this_obj.paras.count,
                limit: this_obj.paras.rows,
                theme: '#3499DB',
                layout: ['count', 'prev', 'page', 'next'],
                jump: function (obj, first) {
                    if (!first) {
                        var index = obj.curr;
                        this_obj.getData(true, index);
                    }
                }
            });
        };
        this.Click = function (type, replyId) {
            if (this.option.Click.indexOf(',' + replyId + ',') == -1) {
                $.post('/reply/EditReplyPraiseCriticismResult', { type: type, replyId: replyId }, function (result) {
                    if (type == 1) {
                        var pArr = $('.reply_praise_' + replyId);
                        $(pArr).each(function (idx, elm) {
                            var _num = parseInt($(elm).html());
                            _num += 1;
                            $(elm).html(_num)
                        });
                    } else {
                        var pArr = $('.reply_criticism_' + replyId);
                        $(pArr).each(function (idx, elm) {
                            var _num = parseInt($(elm).html());
                            _num += 1;
                            $(elm).html(_num)
                        });
                    }
                    reply.option.Click += replyId + ',';
                });
            } else {
                layer.msg('已经提交过');
            }
        };
        this.submit = function (contentId, replyId) {
            var content = $("#" + contentId).val();
            if (!content) {
                layer.msg('评论内容不能为空');
                return;
            }
            var paras = { articleId: this.paras.articleId, replyId: replyId, content: content };
            console.log(paras);
            $.post('/reply/EditReplyResult', paras, function (result) {
                reply.getData();
            });
        };
    };

    function complain(type, objId) {
        layer.prompt({ title: '请输入举报内容', formType: 2 }, function (content, index) {
            layer.close(index);
            var paras = { type: type, objId: objId, content: content};
            $.post('/Complain/EditComplainResult', paras, function (result) {
                var confirm = layer.confirm('感谢您的举报<br>恳请今后也要继续维护平台利益哦', {
                    closeBtn: 0,
                    btn: ['确定']
                }, function () {
                    layer.close(confirm);
                });
            });
        });
    };
</script>